package org.speedmall.business.amount.core.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.speedmall.amount.api.bo.AmountDecreaseBO;
import org.speedmall.amount.api.bo.AmountIncreaseBO;
import org.speedmall.business.amount.core.service.AmountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author hujiaguo
 * @Package org.speedmall.business.amount.core.controller
 * @date 2024/4/25 13:24:21
 */
@Api(tags = "金额")
@Slf4j
@RestController
@RequestMapping("amount")
public class AmountController {

    @Autowired
    private AmountService amountService;

    @ApiOperation("扣减")
    @PostMapping("increase")
    public void increase(@RequestBody AmountIncreaseBO amountIncreaseBO) {
        // 增加金额
        log.info("账户服务：增加用户{}金额{}元", amountIncreaseBO.getUserId(), amountIncreaseBO.getAmount());
        amountService.increaseAmount(amountIncreaseBO);
    }

    @ApiOperation("扣减")
    @PostMapping("decrease")
    public void decrease(@RequestBody AmountDecreaseBO amountDecreaseBO) {
        // 扣减金额
        log.info("账户服务：扣减用户{}金额{}元", amountDecreaseBO.getUserId(), amountDecreaseBO.getAmount());
        amountService.decreaseAmount(amountDecreaseBO);
    }

}
